home *** CD-ROM | disk | FTP | other *** search
/ GameStar 1998 November (Bonus) / GAMESTAR11B.ISO / ENCYC99 / MM / T620273A.DCR / scripts_1_Class CursorGod.ls < prev    next >
Encoding:
Text File  |  1998-07-02  |  4.2 KB  |  186 lines

  1. property objectList, activeObject, thisStillDown, thisRollOver, thisMouseLoc, newstilldown, newrollover, newmouseloc, sendmouseclick, thestagerect, onstage
  2.  
  3. on new me
  4.   global savedcursor
  5.   set activeObject to 0
  6.   set objectList to []
  7.   set thisRollOver to 0
  8.   set thisStillDown to 0
  9.   set thisMouseLoc to point(-1, -1)
  10.   set newstilldown to 0
  11.   set newrollover to 0
  12.   set newmouseloc to 0
  13.   if voidp(savedcursor) then
  14.     set savedcursor to #plain
  15.   end if
  16.   set thestagerect to rect(0, 0, the stageRight - the stageLeft, the stageBottom - the stageTop)
  17.   set onstage to 0
  18.   return me
  19. end
  20.  
  21. on subscribe me, whichObject
  22.   if getPos(objectList, whichObject) = 0 then
  23.     add(objectList, whichObject)
  24.   end if
  25. end
  26.  
  27. on unsubscribe me, whichObject
  28.   deleteOne(objectList, whichObject)
  29. end
  30.  
  31. on mouseCheck me
  32.   if sendmouseclick then
  33.     set sendmouseclick to 0
  34.     sendoff("mouse click")
  35.   end if
  36.   set theMouseLoc to point(the mouseH, the mouseV)
  37.   set nowonstage to inside(theMouseLoc, thestagerect)
  38.   if nowonstage <> onstage then
  39.     set onstage to nowonstage
  40.     if onstage then
  41.       resetcursor(me)
  42.     end if
  43.   end if
  44.   if onstage then
  45.     areYouThere(me, theMouseLoc)
  46.   end if
  47. end
  48.  
  49. on areYouThere me, xLoc
  50.   set nextstilldown to the stillDown
  51.   set newstilldown to nextstilldown <> thisStillDown
  52.   if newstilldown then
  53.     if nextstilldown then
  54.       set sendmouseclick to 1
  55.     end if
  56.   end if
  57.   set thisStillDown to nextstilldown
  58.   set newmouseloc to xLoc <> thisMouseLoc
  59.   set thisMouseLoc to xLoc
  60.   if activeObject = 0 then
  61.     if not thisStillDown then
  62.       repeat with i in objectList
  63.         set returnThis to areYouThere(i, xLoc)
  64.         if returnThis then
  65.           set activeObject to i
  66.           set newrollover to 1
  67.           set thisRollOver to 1
  68.           sendmouseevents(me, xLoc)
  69.           exit repeat
  70.         end if
  71.       end repeat
  72.     else
  73.       set returnThis to 0
  74.     end if
  75.   else
  76.     set nextrollover to areYouThere(activeObject, thisMouseLoc)
  77.     set newrollover to nextrollover <> thisRollOver
  78.     set thisRollOver to nextrollover
  79.     set returnThis to sendmouseevents(me, thisMouseLoc)
  80.   end if
  81.   return returnThis
  82. end
  83.  
  84. on pointCursor me
  85.   global savedcursor
  86.   set savedcursor to #point
  87. end
  88.  
  89. on grabCursor me
  90.   global savedcursor
  91.   set savedcursor to #grab
  92. end
  93.  
  94. on plainCursor me
  95.   global savedcursor
  96.   set savedcursor to #plain
  97. end
  98.  
  99. on blankCursor me
  100.   global savedcursor
  101.   set savedcursor to #blank
  102. end
  103.  
  104. on sendmouseevents me, xPoint
  105.   set sendmousedown to 0
  106.   set sendmouseup to 0
  107.   set sendmouseenter to 0
  108.   set sendmouseleave to 0
  109.   set sendmousemove to 0
  110.   set sendmousedrag to 0
  111.   set sendmousegone to 0
  112.   if newrollover then
  113.     if thisRollOver then
  114.       set sendmouseenter to 1
  115.     else
  116.       set sendmouseleave to 1
  117.       if not thisStillDown then
  118.         set sendmousegone to 1
  119.       end if
  120.     end if
  121.   end if
  122.   if newstilldown then
  123.     if thisRollOver then
  124.       if thisStillDown then
  125.         set sendmousedown to 1
  126.       else
  127.         set sendmouseup to 1
  128.       end if
  129.     else
  130.       set sendmousegone to 1
  131.     end if
  132.   end if
  133.   if newmouseloc then
  134.     if thisStillDown then
  135.       set sendmousedrag to 1
  136.     else
  137.       if thisRollOver then
  138.         set sendmousemove to 1
  139.       end if
  140.     end if
  141.   end if
  142.   set thistime to the ticks
  143.   if sendmousegone then
  144.     set sendmousedrag to 0
  145.     set sendmousemove to 0
  146.   end if
  147.   if sendmouseenter then
  148.     set sendmouseup to 0
  149.     mouseEvent(activeObject, #mouseEnter, thisMouseLoc)
  150.   end if
  151.   if sendmousedown then
  152.     mouseEvent(activeObject, #mouseDown, thisMouseLoc)
  153.   end if
  154.   if sendmousedrag then
  155.     mouseEvent(activeObject, #mouseDrag, thisMouseLoc)
  156.   end if
  157.   if sendmouseup then
  158.     mouseEvent(activeObject, #mouseUp, thisMouseLoc)
  159.   end if
  160.   if sendmousemove then
  161.     mouseEvent(activeObject, #mouseMove, thisMouseLoc)
  162.   end if
  163.   if sendmouseleave then
  164.     mouseEvent(activeObject, #mouseLeave, thisMouseLoc)
  165.   end if
  166.   if sendmousegone then
  167.     mouseEvent(activeObject, #mouseGone, thisMouseLoc)
  168.     set activeObject to 0
  169.   end if
  170.   return thisRollOver
  171. end
  172.  
  173. on resetcursor me
  174.   global savedcursor
  175.   case savedcursor of
  176.     #point:
  177.       pointCursor(me)
  178.     #grab:
  179.       grabCursor(me)
  180.     #plain:
  181.       plainCursor(me)
  182.     #blank:
  183.       blankCursor(me)
  184.   end case
  185. end
  186.